package br.com.dbsti.agenda;

import br.com.winesys.geta.annotations.Selectable;
import br.com.winesys.geta.annotations.TableColumn;
import br.com.winesys.geta.annotations.TableModel;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PersistenceUnit;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "GEFILIAL")
@SequenceGenerator(name = "SeqFilial", initialValue = 1, allocationSize = 1, sequenceName = "SQ_FILIAL")
@PersistenceUnit(name = "agenda")
@NamedQueries({
    @NamedQuery(name = "Empresa.listCRUD", query = "from Empresa order by nome"),
    @NamedQuery(name = "Empresa.listSelectable", query = "from Empresa order by nome"),
    @NamedQuery(name = "Empresa.loadSelected", query = "from Empresa where codigo = :key")
})
@TableModel({
    @TableColumn(field = "codigo", width = 20),
    @TableColumn(field = "nome", width = 60),
    @TableColumn(field = "cnpj", width = 20)
})
@Selectable(display="nome",key="codigo")
public class Empresa implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SeqFilial")
    private Long codigo;
    @Column(name = "descricao", nullable = false)
    private String nome;
    @Column(length = 14)
    private String cnpj;
    private String endereco;

    public String getCnpj() {
        return cnpj;
    }

    public void setCnpj(String cnpj) {
        this.cnpj = cnpj;
    }

    public Long getCodigo() {
        return codigo;
    }

    public void setCodigo(Long codigo) {
        this.codigo = codigo;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }
}
